package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;

import java.util.List;

public class PopuWindowSelectHxAdapter extends BaseQuickAdapter<HousePayWayBean,BaseViewHolder> {
    private int selectIndex=0;
    private PopuWindowSelectAddress1Adapter.BtncliickCallBack mbtncliickCallBack;
    public PopuWindowSelectHxAdapter(@Nullable List<HousePayWayBean> data,PopuWindowSelectAddress1Adapter.BtncliickCallBack btncliickCallBack) {
        super(R.layout.selectroom_item, data);
        mbtncliickCallBack=btncliickCallBack;
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {
        if (item!=null)
        {
            helper.<TextView>getView(R.id.housepublic_item_item_tv).setText(item.getName());
        }
        else {
            helper.<TextView>getView(R.id.housepublic_item_item_tv).setText("不限");
        }
       if (selectIndex==helper.getPosition())
       {
           helper.<TextView>getView(R.id.housepublic_item_item_tv).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
           helper.<TextView>getView(R.id.housepublic_item_item_tv).setBackgroundResource(R.drawable.button_yellow_12_bg);
           mbtncliickCallBack.callBack(selectIndex,item);
       }else {
           helper.<TextView>getView(R.id.housepublic_item_item_tv).setTextColor(ArmsUtils.getColor(mContext,R.color.white));
           helper.<TextView>getView(R.id.housepublic_item_item_tv).setBackgroundResource(R.drawable.button_gray_12_bg);
       }
        helper.<TextView>getView(R.id.housepublic_item_item_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectIndex=helper.getPosition();
                notifyDataSetChanged();
            }
        });

    }
}
